package usaco.c2007.january.bronze;

import java.util.Arrays;
import java.util.Scanner;

/*
 * p2768
 * USACO 2007 January - Bronze
 */

public class p2768 {
	
	static int C, N;
	static int[] co;
	static int[][] m;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		C = scanner.nextInt();
		N = scanner.nextInt();
		co = new int[N+1];
		co[0] = 0;
		for (int i=1;i<=N;++i) {
			co[i] = scanner.nextInt();
		}
		
		Arrays.sort(co);

		m = new int[C+1][N+1];
		for (int i=1;i<=N;++i) {
			m[0][i] = 0;
		}
		
		for (int i=0;i<=C;++i) {
			if (i % co[1] == 0) {
				m[i][1] = i / co[1];
			}
			else {
				m[i][1] = Integer.MAX_VALUE;
			}
		}
		
		for (int i=1;i<=C;++i) {
			for (int j=2;j<=N;++j) {
				m[i][j] = m[i][j-1];
				for (int k=1;k*co[j]<=i;++k) {
					m[i][j] = Math.min(m[i][j], m[i-k*co[j]][j-1] + k);
				}
				
			}
		}
		
		System.out.println(m[C][N]);
	}

}
